package cn.doitedu.day04

import org.apache.spark.{SparkConf, SparkContext}

object T06_ReduceDemo {

  def main(args: Array[String]): Unit = {

    //1.创建SparkConf
    val conf = new SparkConf().setAppName("WordCount")
      .setMaster("local[4]") //如果提交到集群中运行，setMaster必须注释掉

    //2.创建SparkContext
    val sc = new SparkContext(conf)

    val arr = Array(1, 2,   3, 4, 5,   6, 7,    8, 9, 10)
    val rdd1 = sc.parallelize(arr, 4)

    val sum: Int = rdd1.reduce(_+_)


  }

}
